package com.example240705;

import com.fasterxml.jackson.annotation.JsonIgnore;
import jakarta.persistence.*;
import lombok.*;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

import java.util.ArrayList;
import java.util.List;

@Entity
@Data
@Table(name = "student_info")
@Setter
@Getter
@AllArgsConstructor
@NoArgsConstructor
@DynamicInsert
@DynamicUpdate
public class StudentInfo {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;
    private String id_seq;
    private String name;
    private String gender;
    private Short age;
    private String school;
    private Integer student_num;
    private String subject;
    private String phone;
    private String email;
    private String live_place;
    private String iban;

    @OneToMany(mappedBy = "studentInfo", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
//    @JsonBackReference
//    @JsonManagedReference
//    @Lazy(false)
    @JsonIgnore
    @Fetch(FetchMode.SUBSELECT)
    private List<PhysicalTest> physicalTests = new ArrayList<>();


}
